from pydocx import PyDocX
from Doc import show_output

output_doc='output_doc.docx'
output_html='output_doc.html'

# # <editor-fold desc="pydocx">
# html = PyDocX.to_html(output_doc)
# f = open(output_html, 'w', encoding="utf-8")
# f.write(html)
# f.close()
# # </editor-fold>


import os

# output_doc
output_pdf = 'output.pdf'

import docx2pdf
docx2pdf.convert(output_doc, output_pdf)
# os.system('start ' + output_html)
os.system('start ' + output_pdf)

# # <editor-fold desc="win32__doc2pdf">
# import sys
# import os
# import comtypes.client
#
# wdFormatPDF = 17
#
# # in_file = os.path.abspath(sys.argv[1])
# # out_file = os.path.abspath(sys.argv[2])
# in_file, out_file = os.path.abspath(output_doc), os.path.abspath(output_pdf)
#
# word = comtypes.client.CreateObject('Word.Application')
# doc = word.Documents.Open(in_file)
# doc.SaveAs(out_file, FileFormat=wdFormatPDF)
# doc.Close()
# word.Quit()
# # </editor-fold>

# os.system('start ' + output_pdf)



# # <editor-fold desc="mammoth">
# import mammoth
#
# custom_styles = """ b => b.mark
#                     u => u.initialism
#                     i => strong
#                     comment-reference => sup
#                     p[style-name='Heading 1'] => h1.card
#                     table => table.table.table-hover
#                     """
#
# with open(output_doc, "rb") as docx_file:
#     result = mammoth.convert_to_html(docx_file, style_map=custom_styles)
#     text = result.value # The raw text
#     with open(output_html, 'w') as text_file:
#         text_file.write(text)
# # </editor-fold>

# <editor-fold desc="win32">
# import win32com.client
#
# doc = win32com.client.GetObject(output_doc)
# doc.SaveAs(FileName=output_html, FileFormat=8)
# doc.Close()
# </editor-fold>

# html = convert('path/to/docx/file')
# os.system('start ' + output_html)

# show_output(output_doc, open_type='__all__')

